package com.zhiwang.planet.widget

import android.content.Context
import androidx.appcompat.app.AlertDialog
import android.view.LayoutInflater
import com.zhiwang.planet.R
import kotlinx.android.synthetic.main.simple_input_dialog_layout.view.*

class InputPromotionDialog {

    companion object {

        fun create(context: Context, listener: OnPromoteListener) {
            val layoutInflater = LayoutInflater.from(context)
            val view = layoutInflater.inflate(R.layout.simple_input_dialog_layout, null)
            val alertDialog = AlertDialog.Builder(context,R.style.InputDialogInputStyle)
                    .setView(view)
                    .setPositiveButton("确定") { dialog, which ->
                        listener.onPromote(view.payPwdEditor.text.toString())
                        dialog.dismiss()
                    }.setNegativeButton("取消") { dialog, i ->
                        dialog.dismiss()
                    }.create()

            alertDialog.show()
//            alertDialog.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
        }

        interface OnPromoteListener {
            fun onPromote(pwd: String)
        }
    }
}